package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.assemblyEquipmentPojo;
import com.example.pojo.faultHistoryPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:assemblyEquipmentMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/9/28 20:01
 * @Version 1.0
 */
@Mapper
public interface assemblyEquipmentMapp {

    //在主表中插入一行数据
    @DS("baodingRussia")
    @Insert("insert into assemblyEquipmentList " +
            "(op, equipmentName, equipmentType, " +
            "equipmentItem, equipmentId, drawingNo, " +
            "modelId, faultHistory, maintenance, " +
            "oil, fasten, calibration, " +
            "electrical, others, deleteSign, " +
            "establishTime, updateTime, editName, " +
            "workshop) " +
            "VALUES " +
            "(#{op},#{equipmentName},#{equipmentType}," +
            "#{equipmentItem},#{equipmentId},#{drawingNo}," +
            "#{modelId},#{faultHistory},#{maintenance}," +
            "#{oil},#{fasten},#{calibration}," +
            "#{electrical},#{others},#{deleteSign}," +
            "#{establishTime},#{updateTime},#{editName}," +
            "#{workshop})")
    void insertOne(assemblyEquipmentPojo assemblyEquipmentPojo);
    //根据两个字段查询出大表数据
    @DS("baodingRussia")
    @Select("select * from assemblyEquipmentList where ${firstFiledName}=#{firstFiledVal} and ${secondFiledName}=#{secondFiledVal} and deleteSign=1")
    List<assemblyEquipmentPojo> inquiryByTowFiled(String firstFiledName, String firstFiledVal, String secondFiledName, String secondFiledVal);
    //根据id，修改一行数据
    @DS("baodingRussia")
    @Update("update assemblyEquipmentList set " +
            "equipmentName=#{equipmentName}," +
            "equipmentType=#{equipmentType}," +
            "equipmentItem=#{equipmentItem}," +
            "equipmentId=#{equipmentId}," +
            "modelId=#{modelId}," +
            "editName=#{editName}," +
            "updateTime=#{updateTime}," +
            "establishTime=#{establishTime}," +
            "deleteSign=#{deleteSign} " +
            "where id=#{id}")
    void editById(assemblyEquipmentPojo assemblyEquipmentPojo);
    //根据传来的数据，修改一个字段，根据id修改
    @DS("baodingRussia")
    @Update("update assemblyEquipmentList set ${filedName}=#{filedVal} where id=#{id}")
    void EditOneById(Integer id, String filedName, String filedVal);

    @DS("baodingRussia")
    @Insert("insert into faultHistory (" +
            "`describe`, date, timeProblem, " +
            "firstTime, firstName, number, " +
            "proPer, stopTime, reason, " +
            "method, metPer, metEndTime, " +
            "extend, extDate, extPer, " +
            "editTime, otherInfo, problemName, " +
            "deleteSign, establishTime, updateTime, " +
            "editName, workshopPer, workshopTime," +
            "op) " +
            "VALUES (" +
            "#{describe}, #{date}, #{timeProblem}," +
            " #{firstTime}, #{firstName}, #{number}," +
            " #{proPer}, #{stopTime}, #{reason}," +
            " #{method}, #{metPer}, #{metEndTime}," +
            " #{extend}, #{extDate}, #{extPer}," +
            " #{editTime}, #{otherInfo}, #{problemName}," +
            " #{deleteSign}, #{establishTime}, #{updateTime}, " +
            "#{editName},#{workshopPer},#{workshopTime},#{op})")
    void assemblyEquipmentFaultHistoryInsert(faultHistoryPojo faultHistoryPojo);
    //设备人员到位了，要处理问题，进行到位时间记录，筛选出本序还没有人处理的问题
    @DS("baodingRussia")
    @Select("select * from faultHistory where op=#{op}")
    List<faultHistoryPojo> assemblyEquipmentFaultHistoryFirstReach(String op);
}
